package com.fh.service.ccode;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.fh.dao.DAO;
import com.fh.dao.DaoSupport;
import com.fh.util.PageData;

@Service("solutionService")
public class SolutionService {

	@Resource(name = "daoSupport")
	private DaoSupport dao;
	
	
	@SuppressWarnings("unchecked")
	public List<PageData> getMissionPerson(PageData pd) throws Exception
	{
		return (List<PageData>) dao.findForList("SolutionsMapper.getMissionPerson", pd);
	}


	public void addSolution(PageData pd) throws Exception{
		dao.save("SolutionsMapper.addSolution", pd);
	}


	@SuppressWarnings("unchecked")
	public List<PageData> getSolutionList(PageData pd) throws Exception{
		return (List<PageData>) dao.findForList("SolutionsMapper.getSolutionList", pd);
	}


	public PageData getOneSolution(PageData pd) throws Exception{
		return (PageData) dao.findForObject("SolutionsMapper.findSoInfoByID", pd);
	}


	public void addComment(PageData pd) throws Exception{
		dao.save("SolutionsMapper.saveSoComment", pd);
	}
	
	@SuppressWarnings("unchecked")
	public List<PageData> getSoComments(PageData pd) throws Exception{
		return (List<PageData>) dao.findForList("SolutionsMapper.getSoComments", pd);
	}


	public void addGitInfo(PageData pd) throws Exception{
		dao.update("SolutionsMapper.saveGitInfo", pd);
	}


	public void updateCloneStatusToFalse(PageData pd) throws Exception{
		dao.update("SolutionsMapper.updateCloneStatusToFalse", pd);
	}

	public void updateCloneStatusToTrue(PageData pd) throws Exception{
		dao.update("SolutionsMapper.updateCloneStatusToTrue", pd);
	}


	public void updateCloneStatusToDefault(PageData pd) throws Exception{
		dao.update("SolutionsMapper.updateCloneStatusToDefault", pd);		
	}
	
	public void saveCodeInfo(PageData pd) throws Exception {
		dao.update("SolutionsMapper.updateCodeInfo", pd);
	}
	
	public List<PageData> getSimilar(PageData pd) throws Exception{
		return (List<PageData>) dao.findForList("SolutionsMapper.findSimilarCode", pd);
	}
	
	public long checkPermission(PageData pd) throws Exception {
		PageData ret = (PageData) dao.findForObject("SolutionsMapper.checkPermission", pd);
		return (Long) ret.get("PERMISSION");
	}
	
}
